package com.dwxt.sport.admin.controller;

import com.dwxt.common.base.BaseResult;
import com.dwxt.common.base.Page;
import com.dwxt.sport.admin.service.SceneServiceAdmin;
import com.dwxt.sport.entity.Scene;
import com.dwxt.sport.entity.WifeDevice;
import com.dwxt.sport.entity.vo.SceneVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/admin")
@RestController
@Api(tags = {"场景后台相关接口"})
public class SceneControllerAdmin {

    @Autowired
    private SceneServiceAdmin sceneServiceAdmin;

    @PostMapping("/selectScenePage")
    @ApiOperation(value = "查询场景列表", notes = "查询场景列表", response = Scene.class)
    public BaseResult selectScenePage(Page page){
        return sceneServiceAdmin.selectScenePage(page);
    }

    @PostMapping("/createScene")
    @ApiOperation(value = "新增场景", notes = "新增场景", response = BaseResult.class)
    public BaseResult createScene(Scene scene){
        sceneServiceAdmin.createScene(scene);
        return BaseResult.ok();
    }

    @PostMapping("/updateScene")
    @ApiOperation(value = "修改场景", notes = "修改场景", response = BaseResult.class)
    public BaseResult updateScene(Scene scene){
        sceneServiceAdmin.updateScene(scene);
        return BaseResult.ok();
    }

    @PostMapping("/deleteScene")
    @ApiOperation(value = "删除场景", notes = "删除场景", response = BaseResult.class)
    public BaseResult deleteScene(String id){
        sceneServiceAdmin.deleteScene(id);
        return BaseResult.ok();
    }

    @PostMapping("/relateDevice")
    @ApiOperation(value = "关联设备",notes = "关联设备",response = BaseResult.class)
    public BaseResult relateDevice(SceneVo sceneVo){
        sceneServiceAdmin.relateDevice(sceneVo);
        return BaseResult.ok();
    }

    @PostMapping("/selectDetailById")
    @ApiOperation(value = "查询场景详情",notes = "查询场景详情",response = BaseResult.class)
    public BaseResult selectDetailById(String id){
        return sceneServiceAdmin.selectDetailById(id);
    }

}
